package com.itheima.exception;

import com.itheima.entity.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice  //用来捕获控制器controller抛出的异常
public class GlobalExceptionHandler   {

    @ExceptionHandler
    public Result doException(Exception ex)
    {
        log.error(ex.getMessage());
        return Result.error("出错 ");
    }

}
